if(nextphase==1 && stagephase==2){ phase+=1; frame=0; enemyx=0; enemyy=0; enemiescalled=0; nextphase=0; SetCommonData("IncreasePhase",0); }

if(phase==1 && stagephase==2){
	if(enemiescalled==0){ newviewx=0; newviewy=-15; viewmovetimexy=60; }
	if(enemiescalled==5){ newviewx=20; newviewy=-15; viewmovetimexy=60; }
	if(enemiescalled==9){ newviewx=-20; newviewy=-15; viewmovetimexy=120; }
	if(frame%45==0){
		if(enemiescalled==0){ CreateEnemyFromFile("script\Enemies\Stage 6\605.txt",cx,miny-32,0,0,[rand(0,360),1]); }
		if(enemiescalled==5){ CreateEnemyFromFile("script\Enemies\Stage 6\605.txt",cx+100,miny-32,0,0,[rand(0,360),1]); }
		if(enemiescalled==9){ CreateEnemyFromFile("script\Enemies\Stage 6\605.txt",cx-100,miny-32,0,0,[rand(0,360),1]); }
	enemiescalled++; }
	if(enemiescalled>=21){ nextphase=1; }
}
if(phase==2 && stagephase==2){
	if(enemiescalled==0){ newviewx=20; newviewy=0; viewmovetimexy=150; }
	if(enemiescalled==40){ newviewx=-20; newviewy=0; viewmovetimexy=150; }
	if(frame%10==0){
	if(enemiescalled==5){ CreateEnemyFromFile("script\Enemies\Stage 6\605.txt",cx,miny-32,0,0,[rand(0,360),3]); }
	if(enemiescalled<20){
		CreateEnemyFromFile("script\Enemies\Stage 6\606.txt",maxx+32,miny+rand(70,90),0,0,1);
	}
	if(enemiescalled>=40 && enemiescalled<60){
		CreateEnemyFromFile("script\Enemies\Stage 6\606.txt",minx-32,miny+rand(70,90),0,0,1);
	}
	enemiescalled++; }
	if(enemiescalled>=66){ nextphase=1; }
}
if(phase==3 && stagephase==2){
	if(frame%45==0){
		if(enemiescalled==3){
		CreateEnemyFromFile("script\Enemies\Stage 6\605.txt",cx+100,miny-32,0,0,[rand(0,360),2]);
		CreateEnemyFromFile("script\Enemies\Stage 6\605.txt",cx-100,miny-32,0,0,[rand(0,360),2]);
		}
	enemiescalled++; }
	if(enemiescalled>=16){ nextphase=1; }
}
if(phase==4 && stagephase==2){
	if(enemiescalled==0){ newviewx=20; newviewy=0; viewmovetimexy=90; }
	if(enemiescalled==40){ newviewx=-20; newviewy=0; viewmovetimexy=90; }
	if(frame%10==0){
	if(enemiescalled<20){
		CreateEnemyFromFile("script\Enemies\Stage 6\606.txt",maxx+32,miny+rand(70,90),0,0,2);
	}
	if(enemiescalled>=40 && enemiescalled<60){
		CreateEnemyFromFile("script\Enemies\Stage 6\606.txt",minx-32,miny+rand(70,90),0,0,2);
	}
	enemiescalled++; }
	if(enemiescalled>=100){ nextphase=1; }
}
if(phase==5 && stagephase==2){
	if(enemiescalled==3){ newviewx=0; newviewy=-15; viewmovetimexy=300; }
	if(enemiescalled==0){ CreateEnemyFromFile("script\Functions\fadeout-in.txt",0,0,0,0,0); }
	if(enemiescalled==2){ bgphase=3; }
	if(frame%50==0){
	if(enemiescalled<5){
		CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx+100-enemyx,miny-90,0,0,[90+45-enemyx,1]);
		CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx-100+enemyx,miny-90,0,0,[90-45+enemyx,1]);
	}
	enemiescalled++; enemyx+=24; }
	if(enemiescalled>=9){ nextphase=1; }
}
if(phase==6 && stagephase==2){
	if(frame%180==0){
	if(enemiescalled==2){ newviewx=-60; newviewy=15; viewmovetimexy=300; }
		if(enemiescalled==0){
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx-140,miny-90,0,0,[135,2]);
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx-60,miny-90,0,0,[110,2]);
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx,miny-90,0,0,[90,2]);
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx+60,miny-90,0,0,[70,2]);
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx+140,miny-90,0,0,[45,2]);
		}
		if(enemiescalled==1){
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx-140,miny-90,0,0,[25,2]);
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx-60,miny-90,0,0,[60,2]);
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx,miny-90,0,0,[90,2]);
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx+60,miny-90,0,0,[120,2]);
			CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx+140,miny-90,0,0,[155,2]);
		}
	enemiescalled++; }
	if(enemiescalled>=3){ nextphase=1; }
}
if(phase==7 && stagephase==2){
	if(enemiescalled==0){ newviewx=20; newviewy=10; viewmovetimexy=300; }
	if(enemiescalled==6){ newviewx=-10; newviewy=-20; viewmovetimexy=300; }
	if(enemiescalled==12){ newviewx=0; newviewy=0; viewmovetimexy=300; }
	if(frame%60==0){
	if(enemiescalled<16 && enemiescalled%2==0){
		CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx+100,miny-90,0,0,[90+rand(20,60),2]);
		CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx-100,miny-90,0,0,[90-rand(20,60),1]);
	}
	if(enemiescalled<16 && enemiescalled%2!=0){
		CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx+100,miny-90,0,0,[90+rand(20,60),1]);
		CreateEnemyFromFile("script\Enemies\Stage 6\604.txt",cx-100,miny-90,0,0,[90-rand(20,60),2]);
	}
	enemiescalled++; }
	if(enemiescalled>=21){ nextphase=1; }
}
if(phase==8 && stagephase==2){
	if(frame%5==0){ enemiescalled++; }
	if(enemiescalled>=8){ nextphase=1; }
}
if(phase==9 && stagephase==2){
	if(enemiescalled==0){ newviewx=75; newviewy=-15; viewmovetimexy=150; SetCommonData("BackgroundStop",1); }
	if(enemiescalled==4){ nextphase=1; }
	if(frame%60==0){ enemiescalled++; }
}